<template>
  <el-container class="layout-container">
    <el-header>
      <el-menu mode="horizontal">
        <el-menu-item index="1">
          <router-link to="/main/home" style="text-decoration: none;">首页</router-link>
        </el-menu-item>
        <el-menu-item index="2">
          <router-link to="/main/reservation" style="text-decoration: none;">会议室预约</router-link>
        </el-menu-item>
        <el-menu-item index="3">
          <router-link to="/main/myreservations" style="text-decoration: none;">我的预约</router-link>
        </el-menu-item>
        <el-sub-menu index="4" class="user-menu">
          <template #title>
            <el-avatar size="small" :src="user.avatar" />
            {{ user.name }}
          </template>
          <router-link to="/main/profile" style="text-decoration: none;">
            <el-menu-item index="4-1">个人中心</el-menu-item>
          </router-link>
          <el-menu-item index="4-2" @click="handleLogout">退出登录</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </el-header>

    <el-main>
      <div class="content-container">
        <router-view></router-view>
      </div>
    </el-main>

    <el-footer>
      <div class="footer-content">
        <span>智能会议室预约系统</span>
        <span> 2025 All rights reserved</span>
      </div>
    </el-footer>
  </el-container>
</template>

<style scoped>
.content-container {
  padding: 20px;
  background-color: #f5f7fa;
}

</style>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

const user = {
  name: '测试用户',
  avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png'
}

const handleLogout = () => {
  router.push('/login')
}
</script>

<style scoped>
.layout-container {
  min-height: 100vh;
}

.el-header {
  padding: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.user-menu {
  float: right;
}

.el-footer {
  background-color: #f5f5f5;
  padding: 20px 0;
  text-align: center;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #666;
}
</style>
